import ProFrom, {ProFormText} from '@ant-design/pro-form';
import { useRef } from 'react';
import { message, Space } from 'antd';
import {ModalForm} from '@ant-design/pro-form';
import FormModal from "@/pages/user/UserList/components/FormModal";

const waitTime = (time: number = 100) => {
  return new Promise((resolve) => {
    setTimeout(() => {
      resolve(true);
    }, time);
  });
};

const AddPerson=(props) => {
  const {img} = props
  const formRef = useRef();
  return (
    <div
      style={{
        height: '20px',
        lineHeight:'20px'
      }}
    >
      <Space>
        <ModalForm<{
          name: string;
          company: string;
        }>
          title="修改推广人"
          formRef={formRef}
          width={500}
          trigger={
            <h4>修改上级推广人</h4>
          }
          modalProps={{
            forceRender: true,
            destroyOnClose: true,
          }}
          onFinish={async (values) => {
            await waitTime(2000);
            console.log(values.name);
            message.success('提交成功');
            // 不返回不会关闭弹框
            return true;
          }}
        >
          <ModalForm
            title="请选择商城用户"
            formRef={formRef}
            trigger={
              <ProFrom
                submitter={false}
              >
                <ProFormText
                  width="lg"
                  name="name"
                  initialValue={img}
                  label="真实姓名"
                />
              </ProFrom>
            }
            modalProps={{
              forceRender: true,
              destroyOnClose: true,
            }}
            onFinish={async (values) => {
              await waitTime(2000);
              console.log(values.name);
              message.success('提交成功');
              // 不返回不会关闭弹框
              return true;
            }}
          >
            <FormModal/>
          </ModalForm>
        </ModalForm>
      </Space>
    </div>
  );
};

export default AddPerson;
